<template>
    <div ref="chartsRef" class="charts" :style="{height: height+'px'}"></div>
</template>

<script setup lang="ts">
import {onMounted, ref} from "vue";
import * as echarts from 'echarts';
import {simpleGet} from "@/utils/request";

const props = defineProps({
    height:{type:Number, default: 500}
})
const chartsRef = ref()

type EChartsOption = echarts.EChartsOption;

const option: EChartsOption = {
    title: {
        text: '会员佣金排行榜',
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        top: 30,
        type: 'scroll',
        orient: 'vertical',
        left: 'left'
    },
    series: [
        {
            name: '佣金',
            type: 'pie',
            radius: '50%',
            data: [],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};


onMounted(() => {
    const myChart = echarts.init(chartsRef.value!);
    myChart.setOption(option)

    simpleGet('/index/userRewardSort').then(({list}) => {
        myChart.setOption({
            series:{
                data: list
            }
        })
    })

})



</script>

<style scoped>
.charts{
}
</style>
